<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <#include "/common/plateform/include/common-base.ftl">
    <title>规则选用管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
</head>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

    <!-- top start -->
    <#include "/common/plateform/top.ftl">
    <!-- top end -->
    <!-- left start -->
    <#include "/common/plateform/left-project.ftl">
    <!-- left end-->

    <div class="content-wrapper">
        <!-- Main start -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">

                    <!------搜索  start ------->
                    <div class="box box-info">
                        <!--搜索title  start -->
                        <div class="box-header with-border">
                            <h3 class="box-title"><i class="fa fa-search"></i> 规则选用管理
                                [${cateName!''}-${cateNo!''}]
                                <button  onclick="toBack('${page_admin}/project/sysRulesCate-list');" class="btn btn-primary btn-xs" type="button"><i class="fa fa-reply"></i> 返回上级</button>
                            </h3>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool"
                                        data-widget="collapse"><i class="fa fa-minus"></i>
                                </button>
                                <button type="button" class="btn btn-box-tool" data-widget="remove">
                                    <i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <!--搜索title  end -->

                        <div class="box-body">
                            <input type="hidden" value="${r'\${[^\{\}]+\}'}" id="rulesPattern"/>
                            <form id="searchForm" class="form-horizontal">
                                <input type="hidden" name="doCode" value="dymicSql"/>
                                <input type="hidden" name="pageName" value="sysRulesProd-list">
                                <input type="hidden" name="formName" value="searchForm">
                                <input type="hidden" name="sysRulesProd.w_delStatus" value="F">
                                <input type="hidden" name="sysRulesProd.w_cateNo" value="${cateNo!''}">
                                <input type="hidden" name="orderBy" value="sysRulesProd.rules_no,sysRulesProd.order_no+0"/>
                                <input type="hidden" name="ParamType" value="json"/>
                                <input type="hidden" name="sysRulesProd.wi_sysName" class="search_sysName" value=""/>

                                <div class="col-sm-2 text-right"><label class="control-label">
                                    规则编号：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" name="sysRulesProd.wl_rulesNo"
                                           class="form-control clean" value=""/>
                                </div>
                                <div class="col-sm-2 text-right"><label
                                        class="control-label">规则名称：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control clean" name="sysRulesProd.wl_rulesName" value=""/>
                                </div>
                                <div class="col-sm-2 text-right"><label class="control-label">
                                    公式格式：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control clean" name="sysRulesProd.wl_formulaCal"
                                           value=""/>
                                </div>
                                <center>
                                    <center>
                                        <div class="col-sm-12 box-footer clearfix">
                                            <button class="btn btn-success" type="button"
                                                    onclick="getTableData();">
                                                <i class="fa fa-edit-circle"></i>
                                                查询
                                            </button>
                                            <button class="btn btn-warning" type="button"
                                                    onclick="mytools.cleanData('#searchForm');">重置
                                            </button>
                                        </div>
                                    </center>
                            </form>
                        </div>
                    </div>
                    <!------- 搜索 end -------->

                    <!------- 列表 start -------->
                    <div class="box box-success">
                        <!--列表title  start -->
                        <div class="box-header with-border">
                            <h3 class="box-title"><i class="fa fa-table"></i> 规则选用结果列表 [<span id="span-sysname-text"></span>] [共计<span id="dataListTotalCount">0</span>条数据]
                                　　　
                                <button onclick="toAddSysRulesData();" class="btn btn-success"
                                        type="button"><i class="fa fa-plus-circle"></i> 添加规则
                                </button>
                            </h3>
                            <div class="box-tools pull-right">
                                　　　　　　　　
                                <button type="button" class="btn btn-box-tool"
                                        data-widget="collapse"><i class="fa fa-minus"></i>
                                </button>
                                <button type="button" class="btn btn-box-tool" data-widget="remove">
                                    <i class="fa fa-times"></i></button>
                            </div>
                        </div>
                        <!--列表title  end -->
                        <div class="box-body">
                            <table id="dataList" class="table table-bordered table-hover">
                                <thead class="bg-success">
                                <tr>
                                    <th>规则类型</th>
                                    <th>规则编号/排序/规则名称/公式名称/公式类型/公式格式</th>
                                    <th>输入/返回/单位</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="dataList-body">
                                </tbody>
                            </table>
                            <center>
                                <ul id="dataList-page"></ul>
                            </center>
                        </div>
                    </div>
                    <!------- 列表 end -------->
                </div>
            </div>
        </section>

        <div class="modal fade" id="my_modal_add" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="width:1000px;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                        </button>
                        <h4 class="modal-title">
                            <font color="red">选择规则</font> 
                        </h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" role="form" id="sysRulesTemplate-searchForm">
                            <input type="hidden" name="pageName" value="sysRulesTemplate-list"/>
                            <input type="hidden" name="formName" value="searchForm"/>
                            <input type="hidden" name="sysRulesTemplate.wi_sysName" class="search_sysName" value=""/>
                            <input type="hidden" name="sysRulesTemplate.w_delStatus" value="F"/>
                            <input type="hidden" name="orderBy" value="sysRulesTemplate.rules_type,sysRulesTemplate.rules_no,sysRulesTemplate.order_no"/>
                            <div class="form-group">
                                <div class="col-sm-2 text_r"><label
                                        class="control-label">公式名称：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control clean"
                                           name="sysRulesTemplate.wl_formulaName" value=""
                                           id="formulaName"/>
                                </div>
                                <div class="col-sm-2 text_r"><label
                                        class="control-label">规则编号：</label></div>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control clean"
                                           name="sysRulesTemplate.wl_rulesNo" value=""
                                           id="rulesNo"/>
                                </div>
                                <div class="col-sm-4">
                                    <button type="button" class="btn btn-success"
                                            onclick="getSysRulesData();">查询
                                    </button>
                                    <button type="button" class="btn btn-warning"
                                            onclick="FormUtil.cleanData('sysRulesTemplate-searchForm');">
                                        重置
                                    </button>
                                </div>
                            </div>

                        </form>
                        <table class="table table-bordered table-hover">
                            <thead class="bg-success">
                            <tr>
                                <th>规则类型</th>
                                <th>规则编号/排序/规则名称/公式名称/公式类型</th>
                                <th>是否允许输入设置/名称/单位/验证等</th>
                            </tr>
                            </thead>
                            <tbody id="sysRulesTemplate-body">
                            </tbody>
                        </table>
                        <center>
                            <ul id="sysRulesTemplate-page"></ul>
                        </center>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>

        <div class="modal fade" id="my_modal_edit" tabindex="-1" data-backdrop="static"
             data-keyboard="false" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                        </button>
                        <h4 class="modal-title">
                            <font color="red"> 参数设置 | -<span
                                    data-name="sysRulesProd.formulaDesc"></span></font> 
                        </h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" role="form" id="sysVariable_searchForm">
                            <input type="hidden" name="doCode" value="dymicSql"/>
                            <input type="hidden" name="modelTypes" value="s_sysVariable"/>
                            <input type="hidden" id="formToken" name="formToken">

                            <input type="hidden" class="clean"
                                   id="sysVariable_sysRulesProd_rulesParamId"
                                   data-name="sysRulesProd.rulesParamId"
                                   name="sysVariable.w_rulesParamId" value=""/>

                            <div class="box-body">
                                <!-- Custom Tabs -->
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">描述</label>
                                    <div class="col-sm-8">
                                        <span data-name="sysRulesProd.formulaDesc"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">公式</label>
                                    <div class="col-sm-8">
                                        <span id="span_param_formulaSrc"
                                              data-name="sysRulesProd.formulaSrc"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">结果</label>
                                    <div class="col-sm-8">
                                        <input id="txt_param_formulaCal"
                                               data-name="sysRulesProd.formulaCal"
                                               readonly="readonly" class="form-control clean"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-12">
                                        <table class="table table-bordered table-hover">
                                            <thead class="bg-warning">
                                            <tr>
                                                <th>参数key</th>
                                                <th>参数value</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody id="sysVariable-body">
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                <!-- nav-tabs-custom -->
                            </div>
                            <div class="box-footer">
                                <button type="button" class="btn btn-success pull-center btn-lg"
                                        onclick="saveAllRules();"> 设置完成
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>

        <div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="width: 70%">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            ×
                        </button>
                        <h4 class="modal-title">
                            <font color="red">查看详情</font> 
                        </h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" role="form" id="viewForm">
                            <div class="box-body">
                                <!-- Custom Tabs -->
                                <div class="nav-tabs-custom">
                                    <div class="tab-content">
                                        <div class="tab-pane active" id="tab_1">

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">公式算法</label>
                                                <div class="col-sm-10 form-control-static">
                                                    <span data-name="sysRulesProd.formulaCal"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">公式格式</label>
                                                <div class="col-sm-10 form-control-static">
                                                    <span data-name="sysRulesProd.formulaDesc"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">公式名称</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.formulaName"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">是否返回结果：</label>
                                                <div class="col-sm-4 form-control-static"><span
                                                                id="viewForm1_sysRulesProd_resFlag"
                                                                data-dict-cate="yesOrNo"
                                                                data-dict-code="dictItemList"
                                                                data-type-tag="select"
                                                                data-name="sysRulesProd.resFlag"
                                                                data-dict="yesOrNo"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">分类编号<br/><span class="f10">cateNo</span></label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.cateNo"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">分类名称</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.cateName"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">规则编号</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.rulesNo"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">规则名称</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.rulesName"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">触发功能点标识<br/><span class="f10">constantType</span></label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.constantType"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">触发功能点状态<br/><span class="f10">constantStatus</span></label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.constantStatus"></span>
                                                </div>
                                            </div>
                                            <div class="form-group" style="background-color:#eeeeee;">
                                                <label class="col-sm-2 control-label">开发标识参数</label>
                                                <div class="col-sm-8 form-control-static">
                                                    <ul class="f10">
                                                        <li>1)cateNo=<span data-name="sysRulesProd.cateNo"></span>&constantType=<span data-name="sysRulesProd.constantType"></span>&constantStatus=<span data-name="sysRulesProd.constantStatus"></span></li>
                                                        <li>2)cateNo=<span data-name="sysRulesProd.cateNo"></span>&constantType=<span data-name="sysRulesProd.constantType"></span></li>
                                                        <li>3)cateNo=<span data-name="sysRulesProd.cateNo"></span>&constantResult=<span data-name="sysRulesProd.cateNo"></span>Result</li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">处理方式</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <spansysRulesProd-list data-name="sysRulesProd.dealType"></spansysRulesProd-list>
                                                </div>
                                                <label class="col-sm-2 control-label">排序</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.orderNo"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">是否可输入</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.showFlag"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">创建时间</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.createTime"></span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">输入校验规则</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.showValid"></span>
                                                </div>
                                                <label class="col-sm-2 control-label">输入校验说明</label>
                                                <div class="col-sm-4 form-control-static">
                                                    <span data-name="sysRulesProd.showTip"></span>
                                                </div>
                                            </div>

                                        </div>
                                        <!-- /.tab-pane -->
                                    </div>
                                    <!-- /.tab-content -->
                                </div>
                                <!-- nav-tabs-custom -->
                            </div>
                            <div class="box-footer">
                                <button type="button" class="btn btn-success pull-right"
                                        onclick="cannel('view');">关闭
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>

        <!-- 以下是template列表模板的模块区域 -->
        <script type="text/template" id="dataList-template">
            <? for ( var i = 0; i < rows.length; i++) {?>
            <tr>
                <td><?=(i+1)?>.<?=strUtil.doNull(rows[i].sysRulesProd.rulesType,'')?><br/>
                    <span class="fx8 f10">(<?=rows[i].sysRulesProd.constantType?>/<?=rows[i].sysRulesProd.constantStatus?>)</span>
                </td>
                <td>
                    <div class="form-group">
                        <?=rows[i].sysRulesProd.rulesNo?>
                        | <span class="text-green"><?=rows[i].sysRulesProd.orderNo?></span>
                        | <?=strUtil.doNull(rows[i].sysRulesProd.rulesName,'')?>
                        |
                        <span class="fx7"><?=strUtil.doNull(rows[i].sysRulesProd.formulaName,'')?></span>
                        | <span class="fx8">(<?=rows[i].sysRulesProd.dealType?>)</span>
                    </div>
                    <div class="form-group fx12"><?=strUtil.doNull(rows[i].sysRulesProd.formulaCal,'')?></div>
                </td>
                <td><?=strUtil.doNull(rows[i].sysRulesProd.showFlag,'')?> | <?=strUtil.doNull(rows[i].sysRulesProd.resFlag,'')?> | <?=strUtil.doNull(rows[i].sysRulesProd.paramUnit,'')?></td>
                <td>
                    <button type="button" class="btn btn-success btn-xs"
                            onclick="toLoad('<?=rows[i].sysRulesProd.rulesParamId?>','view')">查看
                    </button>
                    <button type="button" class="btn btn-warning btn-xs hidden"
                            onclick="toLoad('<?=rows[i].sysRulesProd.rulesParamId?>','edit');">设置常量
                    </button>
                    <button type="button" class="btn btn-danger btn-xs"
                            onclick="toDele('<?=rows[i].sysRulesProd.rulesParamId?>');">删除
                    </button>
                </td>
            </tr>
            <?}?>
        </script>

        <script type="text/template" id="sysRulesTemplate-template">
            <? for ( var i = 0; i < rows.length; i++) {?>
            <tr>
                <td><?=(i+1)?>.<?=strUtil.doNull(rows[i].sysRulesTemplate.rulesType,'')?></td>
                <td>
                    <div class="form-group">
                        <?=rows[i].sysRulesTemplate.rulesNo?>
                        | <?=rows[i].sysRulesTemplate.orderNo?>
                        | <?=strUtil.doNull(rows[i].sysRulesTemplate.rulesName,'')?>
                        | <?=strUtil.doNull(rows[i].sysRulesTemplate.formulaName,'')?>
                        | <?=rows[i].sysRulesTemplate.dealType?>
                    </div>
                    <div class="form-group fx9"><i
                            class="fa fa-info-circle"></i> <?=strUtil.doNull(rows[i].sysRulesTemplate.formulaDesc,'')?>
                    </div>
                    <div class="form-group fx5"><?=strUtil.doNull(rows[i].sysRulesTemplate.formulaCal,'')?></div>
                </td>
                <td>
                    <form id="addFormRule_<?=rows[i].sysRulesTemplate.rulesId?>" action="javascript:;">
                        <input type="hidden" name="pageName" value="sysRulesProd-list"/>
                        <input type="hidden" name="formName" value="addForm"/>
                        <input type="hidden" name="sysRulesProd.cateId" value="<?=cateId?>"/>
                        <input type="hidden" name="sysRulesProd.cateNo" value="<?=cateNo?>"/>
                        <input type="hidden" name="sysRulesProd.cateName" value="<?=cateName?>"/>
                        <input type="hidden" name="sysRulesProd.sysName" value="<?=rows[i].sysRulesTemplate.sysName?>"/>
                        <input type="hidden" name="sysRulesProd.formulaCal" value="<?=rows[i].sysRulesTemplate.formulaCal ?>"/>
                        <input type="hidden" name="sysRulesProd.formulaSrc" value="<?=rows[i].sysRulesTemplate.formulaCal ?>"/>
                        <input type="hidden" name="sysRulesProd.formulaDesc" value="<?=rows[i].sysRulesTemplate.formulaDesc ?>"/>
                        <input type="hidden" name="sysRulesProd.paramName" value="<?=rows[i].sysRulesTemplate.formulaName?>"/>
                        <input type="hidden" name="sysRulesProd.formulaNo" value="<?=rows[i].sysRulesTemplate.formulaNo?>"/>
                        <input type="hidden" name="sysRulesProd.rulesId" value="<?=rows[i].sysRulesTemplate.rulesId?>"/>
                        <input type="hidden" name="sysRulesProd.rulesNo" value="<?=rows[i].sysRulesTemplate.rulesNo?>"/>
                        <input type="hidden" name="sysRulesProd.rulesName" value="<?=rows[i].sysRulesTemplate.rulesName?>"/>
                        <input type="hidden" name="sysRulesProd.rulesType" value="<?=rows[i].sysRulesTemplate.rulesType?>"/>
                        <input type="hidden" name="sysRulesProd.dealType" value="<?=rows[i].sysRulesTemplate.dealType?>"/>
                        <input type="hidden" name="sysRulesProd.constantType" value="<?=rows[i].sysRulesTemplate.nodeType?>"/>
                        <input type="hidden" name="sysRulesProd.constantStatus" value="<?=rows[i].sysRulesTemplate.nodeStatus?>"/>
                        <input type="hidden" name="sysRulesProd.orderNo" value="<?=rows[i].sysRulesTemplate.orderNo?>"/>
                        <input type="hidden" name="sysRulesProd.resFlag" value="<?=rows[i].sysRulesTemplate.resFlag?>"/>

                        <div class="form-group" style="line-height:26px;font-size:12px;">
                            <div>允许设置:<?=isRadioFlag?>
                                <?if(rows[i].sysRulesTemplate.formulaCal.indexOf('{{param}}')>-1){?>
                                    <input type="radio" name="sysRulesProd.showFlag" value="T" checked/> 是
                                    <input type="radio" name="sysRulesProd.showFlag" value="F"/> 否
                                <?}else{?>
                                    <input type="radio" name="sysRulesProd.showFlag" value="T"/> 是
                                    <input type="radio" name="sysRulesProd.showFlag" value="F" checked/> 否
                                <?}?>
                                &nbsp;&nbsp;
                                <button type="button" class="btn btn-danger btn-xs" onclick="addRulesItem('addFormRule_<?=rows[i].sysRulesTemplate.rulesId?>','<?=rows[i].sysRulesTemplate.rulesNo?>');">
                                    选用
                                </button>
                            </div>
                            <div>
                                标题名称:<input type="" name="sysRulesProd.formulaName" style="width:180px;font-size:12px;" value="<?=rows[i].sysRulesTemplate.formulaName?>"/>
                            </div>
                            <div>
                                输入验证:<select name="sysRulesProd.showValid" style="width:180px;font-size:12px;">
                                    <option value="">--选择输入验证--</option>
                                    <option value="^[0-9]*$">只能是数字</option>
                                    <option value="^-?\d+$">只能是正负整数</option>
                                    <option value="^[0-9]+(.[0-9]{1,2})?$">最多两位小数数字</option>
                                    <option value="^([1]?[0-9]|2[0-3]):[0-5][0-9]-([1]?[0-9]|2[0-3]):[0-5][0-9]$">
                                        时间9:00-11:00
                                    </option>
                                </select>
                            </div>
                            <div>
                                验证提示:<input type="text" name="sysRulesProd.showTip" style="width:180px;font-size:12px;"/>
                            </div>
                            <div>
                                其他单位:<input type="text" size="20" name="sysRulesProd.paramUnit" style="width:180px;font-size:12px;" placeholder="单位描述：如%/天/个/小时/秒等"/>
                            </div>
                        </div>
                        <div class="form-group">

                            <!--
                            <div class="col-sm-5" style="display:none;">
                                缺省：<input type="text" class="form-control"
                                          name="sysRulesProd.paramNo"/>
                            </div>
                            -->
                        </div>
                    </form>
                </td>
                <td>
                    <div class="form-group pull-right">

                    </div>
                </td>
            </tr>
            <?}?>
        </script>

        <script type="text/template" id="sysVariable-template">
            <? for ( var i = 0; i < rows.length; i++) {?>
            <tr>
                <td><?=rows[i].paramKey?></td>
                <td><input id="variableTxt-<?=rows[i].infoId?>" onblur="fullRulesCal()"
                           mvar="<?=rows[i].paramKey?>"
                           name="sysVariable-formulaCal-<?=rows[i].rulesParamId?>"
                           class="form-control sysVariablefcal"
                           value="<?=strUtil.doNull(rows[i].paramValue,'')?>"/></td>
                <td>
                    <button type="button" class="btn btn-warning btn-xs"
                            onclick="saveVariable('variableTxt-<?=rows[i].infoId?>','<?=rows[i].infoId?>');">
                        保存设置
                    </button>
                      
                </td>
            </tr>
            <?}?>
        </script>


        <!-- 以下是js模块区域 -->
        <script>
            var clickMenu = "sysRulesCate-list";
            var id, myPage, dataListId, searchFormId, isShowLog, tableSort, tableId;
            myPage = 20;
            dataListId = "dataList";
            searchFormId = "searchForm";
            tableSort = "sysRulesProd";
            tableId = "rulesParamId";
            isShowLog = true;
            var cateId = "${cateId!''}",cateNo = "${cateNo!''}",cateName = "${cateName!''}";
            var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
            $("#span-sysname-text").text(defSysEname+"-"+strUtil.getLocalStorage("sysCname"));
            // if(defSysEname=='plateform'){
            //     $(".search_sysName").val('');
            // }else{
            //     $(".search_sysName").val(defSysEname);
            // }
            $(".search_sysName").val(defSysEname);
            $(".search_cateNo").val(cateNo);
            $(".search_cateName").val(cateName);


            $(function () {
                //1、加载分页列表数据
                getTableData();
                //2、控制是否启用token
                //setToken();

                //请在下面补充其他初始化方法（如数据字典、页面加载数据等）

            });

            //读取（查询、编辑）数据
            function toLoad(id, type) {
                //var paramLoadData = {"sysRulesProd.w_rulesParamId":id,"modelTypes":"s_"+tableSort};
                var paramLoadData = {
                    "sysRulesProd.w_rulesParamId": id,
                    "pageName": "sysRulesProd-list",
                    "formName": "searchForm"
                };
                loadObj(type, paramLoadData);
            }

            function toDele(id) {
                var index_submit = layer.confirm('您确定要删除信息吗？', {
                        btn: ['Yes', 'No'],
                        closeBtn: 0,
                        offset: '220px'
                    }
                    , function () {
                        layer.close(index_submit);
                        var paramLoadData = {
                            "pageName": "sysRulesProd-list",
                            "formName": "delForm",
                            "sysRulesProd.w_rulesParamId": id
                        };
                        //var paramLoadData = {"modelTypes":"u_sysRulesProd","sysRulesProd.delStatus":"T","sysRulesProd.w_rulesParamId":id};
                        doDele(paramLoadData);
                    });
            }

            //反显数据
            function showData(type, myData) {
                console.log(myData);
                if ("view" == type) {
                    FormUtil.loadView("sysRulesProd", myData.sysRulesProd);
                    $("#my_modal_view").modal("show");
                } else if ("edit" == type) {
                    cleanData("sysVariable_searchForm");
                    FormUtil.loadView("sysRulesProd", myData.sysRulesProd);
                    $("#my_modal_edit").modal("show");
                    getVariableData();
                }
            }

            $(function () {
                $('#' + dataListId + ' tbody').on('click', 'tr', function (e) {
                    if ($(this).hasClass('selected')) {
                        //$(this).removeClass('selected');
                    }
                    else {
                        $('tr.selected').removeClass('selected');
                        $(this).addClass('selected');
                    }
                    id = $('tr.selected td').eq(0).html();
                    //  console.log($('tr.selected td').eq(1).html())
                });


            });

            function toBack(url){
                var page="1";
                if(page){
                    sessionStorage.setItem("page",page);
                }
                mytools.pjax(url);
            }

            //加载列表数据
            function getTableData() {
                $.ajax({
                    type: 'get',
                    url: common_list_url,
                    data: $("#" + searchFormId).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchFormId).serialize(), myPage),
                    dataType: 'json',
                    success: function (myData) {
                        console.log(myData);
                        $("#dataListTotalCount").text(myData.total);
                        var data = baidu.template(dataListId + "-template", eval(myData));
                        $("#" + dataListId + "-body").html(data);
                        var option = {
                            ele: $("#" + dataListId + "-page")[0],
                            total: myData.total,
                            fn: getTableData,
                            url: common_list_url + "?" + $("#" + searchFormId).serialize()
                        }
                        generatePages(option);
                    }
                });
            }

            //打开添加规则页面
            function toAddSysRulesData() {
                cleanData('sysRulesTemplate-searchForm');//清空模态窗口内数据
                getSysRulesData();
                $('#my_modal_add').modal('show');
            }

            //验证此分类是否存在重复规则。
            function checkRulesList(rulesNo) {
                var f = false;
                $.ajax({
                    type: "get",
                    url: common_list_url,
                    data: {
                        "pageName": "sysRulesProd-list",
                        "formName": "searchForm",
                        "sysRulesProd.w_cateNo": cateNo,
                        "sysRulesProd.w_sysName": defSysEname,
                        "sysRulesProd.w_rulesNo": rulesNo
                    },
                    dataType: "json",
                    async: false,
                    success: function (myData) {
                        console.log(myData);
                        if (myData.flag == "T" && myData.total > 0) {
                            f = true;
                        }
                    }
                });
                return f;
            }

            //添加规则定义
            function addRulesItem(formId, rulesNo) {
                var f = checkRulesList(rulesNo);

                var index_load = layer.msg("规则["+rulesNo+"]正在保存中。。。", {shade: false, offset: '220px'});
                if (!f) {
                    $.ajax({
                        type: "post",
                        url: common_submit_url,
                        data: $("#" + formId).serialize(),
                        dataType: "json",
                        success: function (myData) {
                            console.log(myData);
                            if (myData.flag == "T") {
                                //addRulesItemChild(myData.ids.sysRulesProd_rulesParamId, formulaCal, index_load);
                                getTableData();
                                layer.close(index_load);
                                // layer.msg("规则["+rulesNo+"]添加成功！");
                            } else {
                                layer.alert(myData.msg);
                            }
                        }
                    });
                } else {
                    layer.alert("此规则["+rulesNo+"]已经存在！");
                }
            }

            //添加规则变量
            function addRulesItemChild(rulesParamId, formulaCal, index_load) {
                //按照正则解析其中变量，分割出输入文本框
                //按照正则匹配：
                var regex = new RegExp(document.getElementById("rulesPattern").value, "g");
                var result = formulaCal.match(regex);
                if (null == result || 0 == result.length) {
                    layer.alert("添加规则成功！");
                    layer.close(index_load);
                    return false;
                }
                layer.alert("此规则存在常量,请单独设置!");
                var strResult = "";
                for (var i = 0; i < result.length; ++i) {
                    var paramKey = result[i];
                    $.ajax({
                        type: "post",
                        url: common_submit_url,
                        data: {
                            "doCode": "dymicSql",
                            "modelTypes": "i_sysVariable",
                            "sysVariable.rulesParamId": rulesParamId,
                            "sysVariable.paramKey": paramKey
                        },
                        dataType: "json",
                        async: false,
                        success: function (myData) {
                            if (i == (result.length - 1)) {
                                layer.close(index_load);
                            }
                        }
                    });
                }
            }

            //加载系统级别规则列表
            function getSysRulesData() {
                //去除搜索空格
                $("#formulaName").val($("#formulaName").val().trim());
                $("#rulesNo").val($("#rulesNo").val().trim());

                var dataListId2 = "sysRulesTemplate";
                var searchForm2 = "sysRulesTemplate-searchForm";
                deleteAllRow(dataListId2);
                $.ajax({
                    type: 'get',
                    url: common_list_url,
                    data: $("#" + searchForm2).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchForm2).serialize(), 10),
                    dataType: 'json',
                    success: function (myData) {
                        myData.cateId=cateId;
                        myData.cateNo=cateNo;
                        myData.cateName=cateName;
                        console.log(myData);
                        var data = baidu.template(dataListId2 + "-template", eval(myData));
                        $("#" + dataListId2 + "-body").html(data);
                        var option = {
                            ele: $("#" + dataListId2 + "-page")[0],
                            total: myData.total,
                            fn: getSysRulesData,
                            url: common_list_url + "?" + $("#" + searchForm2).serialize()
                        };
                        generatePages(option);
                    }
                });
            }

            //加载系统分类具体规则元素列表
            function getVariableData() {
                var dataListId3 = "sysVariable";
                var searchForm3 = "sysVariable_searchForm";
                deleteAllRow(dataListId3);
                $.ajax({
                    type: 'get',
                    url: common_list_url,
                    data: $("#" + searchForm3).serialize(),
                    dataType: 'json',
                    success: function (myData) {
                        if (isShowLog) console.log(myData);
                        var data = baidu.template(dataListId3 + "-template", eval(myData));
                        $("#" + dataListId3 + "-body").html(data);
                    }
                });
            }

            function saveVariable(txtId, infoId) {
                var paramVal = $("#" + txtId).val();
                if (strUtil.isNull(paramVal)) {
                    layer.tips("请输入参数" + $("#" + txtId).attr("mvar") + "的值", '#' + txtId, {tips: 3});
                    $("#" + txtId).focus();
                    return;
                }
                var paramData = {
                    "modelTypes": "u_sysVariable",
                    "sysVariable.paramValue": paramVal,
                    "sysVariable.w_infoId": infoId
                };
                $.ajax({
                    type: "post",
                    url: common_submit_url + "?doCode=dymicSql",
                    data: paramData,
                    dataType: "json",
                    success: function (myData) {
                        var result = myData.flag;
                        if (result == "T") {
                            layer.tips("保存成功", '#' + txtId, {tips: [3, '#008d4c']});
                        }
                    }
                });
            }


            //保存设置完成
            function saveAllRules() {
                var size = $(".sysVariablefcal").length;
                var l = 0;
                $(".sysVariablefcal").each(function (i) {
                    if (strUtil.isNull($(this).val())) {
                        var txtId = $(this).attr("id");
                        layer.tips("请输入参数" + $(this).attr("mvar") + "的值", '#' + txtId, {tips: 3});
                        $("#" + txtId).focus();
                        return false;
                    }
                    l = (i + 1);
                });
                //alert(size+"-"+l);
                if (l < size) return;

                var index_submit = layer.confirm('您确定要提交信息吗？', {
                        btn: ['Yes', 'No'],
                        closeBtn: 0,
                        offset: '220px'
                    }
                    , function () {

                        var srrparamId = $("#sysVariable_sysRulesProd_rulesParamId").val();
                        var sour = $("#txt_param_formulaCal").val();

                        layer.close(index_submit);
                        var index_load = layer.load(2, {shade: false, offset: '220px'});
                        var paramData = {
                            "modelTypes": "u_sysRulesProd",
                            "sysRulesProd.formulaCal": sour,
                            "sysRulesProd.w_rulesParamId": srrparamId
                        };
                        $.ajax({
                            type: "post",
                            url: common_submit_url + "?doCode=dymicSql",
                            data: paramData,
                            dataType: "json",
                            success: function (myData) {
                                var result = myData.flag;
                                if (result == "T") {
                                    layer.alert("保存设置成功");
                                    layer.close(index_load);
                                    $('#my_modal_edit').modal('hide');
                                }
                            }
                        });
                    }, function () {
                    });


            }

            //替换变量合并参数值，实时显示结果
            function fullRulesCal() {
                var srrparamId = $("#sysVariable_sysRulesProd_rulesParamId").val();
                var sour = $("#span_param_formulaSrc").attr("data-val");
                $("input[name='sysVariable-formulaCal-" + srrparamId + "'").each(function () {
                    var key = $(this).attr("mvar");
                    var val = $(this).val();
                    //alert(key+"-"+val);
                    if (val) {
                        sour = sour.replace(key, val);
                    }
                });
                $("#txt_param_formulaCal").val(sour);
            }


            //设置模态框隐藏事件
            $('#my_modal_add').on('show.bs.modal', function (e) {
                $.ajax({
                    type: 'get',
                    url: '${ctx}/sendPage/token?token=true',
                    dataType: 'json',
                    success: function (myData) {
                        if (isShowLog) console.log(myData);
                        $('#formToken').val(myData);
                    }
                });
            });

            //清空数据
            function cleanData(id) {
                $('#' + id).find(".clean").val("");//按照样式清空；
            }

            //打开添加页面
            function toAdd() {
                cleanData('submitFormData');//情况模态窗口内数据
                $("#w_" + tableId).val("");
                $(".datepicker").val("");
                $('#my_modal_add').modal('show');
            }

            //获取对象值
            function loadObj(type, paramData) {
                $.ajax({
                    type: 'get',
                    url: common_info_url + "?doCode=dymicSql",
                    data: paramData,
                    async: false,
                    dataType: "json",
                    success: function (myData) {
                        showData(type, myData);
                    }
                });
            }

            //删除信息（逻辑删除）
            function doDele(paramData) {
                $.ajax({
                    type: "post",
                    url: common_submit_url,
                    data: paramData,
                    dataType: "json",
                    success: function (myData) {
                        var result = myData.flag;
                        if (result == "T") {
                            layer.alert("删除操作成功");
                            refresh();
                        }
                    }
                });
            }


            //关闭win
            function cannel(type) {
                if (strUtil.isNull(type)) {
                    $('#my_modal_add').modal('hide');
                } else {
                    $('#my_modal_' + type).modal('hide');
                }
            }

            function refresh() {
                getTableData();
            }


            function setToken() {
                $.ajax({
                    type: 'get',
                    url: '${ctx}/sendPage/token?token=true',
                    dataType: 'text',
                    success: function (myData) {
                        console.log(myData);
                        $('#formToken').val(myData);
                    }
                });
            }

        </script>


        <!-- Main end -->
    </div>
    <!-- /.content-wrapper -->
    <!-- foot start -->
    <#include "/common/plateform/foot.ftl">
    <!-- foot start -->
</div>
</body>

</html>






